<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/common.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<title>登录</title>
<!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
<script>
	if (window.top !== window.self) {
		window.top.location = window.location;
	}
</script>
</head>
<body class="signin">
	<div>
		<div class="signinpanel">
			<div class="row">
				<div class="col-sm-3">&nbsp;</div>
				<div class="col-sm-6">
					<form id="signupForm">
						<h3 class="text-center">欢迎登录办税服务厅办公管理系统</h3>
						<p class="m-t-md text-center">请输入账户和密码</p>
						<!--  欺骗浏览器 的自动填充 -->
						<input type="text" style=" position: absolute; z-index: -111;" />
						<input type="password" style="  position: absolute; z-index: -111;" />
						<input type="text" id="userAccount" class="form-control uname" value="" />
						<input type="password" id="userPwd" class="form-control pword m-b" value="" />

						  <input type="text" id="code"
                           class="form-control" value=""/><a><img id="captcha" src="${ctx }/index/images/captcha?time=" />
                           </a>
						<button type="button" class="btn btn-login btn-block" id="loginBt">马&nbsp;&nbsp;上&nbsp;&nbsp;登&nbsp;&nbsp;录</button>
					</form>
				</div>

			</div>
		</div>

	</div>
</body>
<script>
	$("#loginBt").click(function() {
		signIn();
	});
	document.onkeydown = function(e) {
		var ev = document.all ? window.event : e;
		if (ev.keyCode == 13) {
			signIn();
		}
	}

	function signIn() {
		var userPwd = $("#userPwd").val();
		var userName = $("#userAccount").val();
		var code = $("#code").val();
		if (userPwd == "" || userName == "" || code== "") {
			toastr.info('请输入用户名、密码和验证码！');
			return false;
		}

		$.post("${ctx}/sys/login/", {
			loginName : userName,
			password : userPwd,
			code : code
		}, function(data, status) {
			if (data.code == 0) {
				window.location.href = "${ctx}/sys/index/"
			} else {
				toastr.error(data.msg);
				$("#captcha").attr("src","${ctx }/index/images/captcha?time="+new Date())
			}
		}).error(function(xhr, errorText, errorType) {
			toastr.error('服务器发生错误！');
		});
	}
</script>
</html>
